package com.hzhr.iot.statis.service;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.CygQuery;
import com.hzhr.iot.core.annotation.CygQuerys;
import com.hzhr.iot.core.annotation.CygService;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.core.util.HzhrDateUtil;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.statis.convertor.DeptMonthlyGasConsumeConvertor;
import com.hzhr.iot.statis.dao.DeptMonthlyGasConsumeDao;
import com.hzhr.iot.statis.dao.mapper.custom.DeptMonthlyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.entity.DeptMonthlyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeptMonthlyGasConsumeEntityExt;
import com.hzhr.iot.statis.model.deptMonthlyGasConsume.DeptMonthlyGasConsumeGetModel;
import com.hzhr.iot.statis.model.deptMonthlyGasConsume.DeptMonthlyGasConsumeModel;
import com.hzhr.iot.statis.model.deptMonthlyGasConsume.dataSum.DeptMonthlyGasConsumeDataSumModel;
import com.hzhr.iot.statis.model.deptMonthlyGasConsume.monthDataSum.DeptMonthlyGasConsumeMonthDataSumModel;
import com.hzhr.iot.statis.queryModel.custom.DeptMonthlyGasConsumeCustomQueryModel;
import com.hzhr.iot.statis.service.base.BaseService;
import com.hzhr.iot.statis.service.helper.User_DeptServiceHelper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
@CygService(entity = DeptMonthlyGasConsumeEntity.class, model = DeptMonthlyGasConsumeModel.class)
@CygQuerys({
        @CygQuery(name = "_equal_deptId", query = "equal_deptId", type = Integer.class),
        @CygQuery(name = "_equal_companyId", query = "equal_companyId", type = Integer.class),
        @CygQuery(name = "_equal_gasUserType", query = "equal_gasUserType", type = String.class),
        @CygQuery(name = "_greaterthan_date", query = "greaterthan_date", type = Date.class),
        @CygQuery(name = "_greaterthanorequal_date", query = "greaterthanorequal_date", type = Date.class),
        @CygQuery(name = "_lessthan_date", query = "lessthan_date", type = Date.class),
        @CygQuery(name = "_lessthanorequal_date", query = "lessthanorequal_date", type = Date.class),
        @CygQuery(name = "_orderBy_date", query = "orderBy_date", type = String.class),

})
public class DeptMonthlyGasConsumeService extends BaseService {
    @Autowired
    DeptMonthlyGasConsumeConvertor deptMonthlyGasConsumeConvertor;
    @Autowired
    DeptMonthlyGasConsumeDao deptMonthlyGasConsumeDao;
    @Autowired
    User_DeptServiceHelper user_deptServiceHelper;
    @Autowired
    DeptMonthlyGasConsumeEntityCustomMapper deptMonthlyGasConsumeEntityCustomMapper;


    //region javadoc注释 : get
    /**
     * 查询登录用户管辖部门的月用气量情况 <br/><br/>
     * 简介&nbsp;:&nbsp;查询登录用户管辖部门的月用气量情况 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询登录用户的所有管辖部门：(√) <br/>
     * &nbsp;使用GLOBAL方式调用部门服务获取用户管辖范围内的所有部门模型对象deptModelList_1， <br/>
     * &nbsp;条件参数如下： <br/>
     * &nbsp;_like_resourceCode&nbsp;=&nbsp;登录用户.userCode&nbsp;+&nbsp;'%'； <br/>
     * &nbsp;然后提取deptModelList_1元素的id属性，得到id属性集合deptIdlist_1； <br/>
     * 2.&nbsp;查询管辖部门的月用气量：(√) <br/>
     * &nbsp;根据条件参数查询管辖部门的月用气量(DEPT_MONTHLY_GAS_CONSUME)对象集合deptMonthlyGasConsumeList_1及总数， <br/>
     * &nbsp;额外筛选规则如下： <br/>
     * &nbsp;deptMonthlyGasConsumeList_1[i].deptId&nbsp;in&nbsp;deptIdlist_1； <br/>
     * 3.&nbsp;返回信息：(√) <br/>
     * &nbsp;根据条件参数和查询到的deptMonthlyGasConsumeList_1及总数生成结果对象并返回； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_total : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示总数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _is_paging : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否分页;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/>
     * _page : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 页数;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _count : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 每页数量;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 1;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_deptId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.deptId = #{_equal_deptId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_companyId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.companyId = #{_equal_companyId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_gasUserType : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.gasUserType = #{_equal_gasUserType};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _greaterthan_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.date > #{_greaterthan_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _greaterthanorequal_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.date >= #{_greaterthanorequal_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _lessthan_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.date < #{_lessthan_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _lessthanorequal_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptMonthlyGasConsume.date <= #{_lessthanorequal_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _orderBy_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 排序 : order by deptMonthlyGasConsume.date #{_orderBy_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/><br/>
     * @throws ServiceException <br/>
     * @see DeptMonthlyGasConsumeGetModel result <br/>
     */ 
    //endregion
    //region 说明 : get
    //查询登录用户管辖部门的月用气量情况
    //简介 : 查询登录用户管辖部门的月用气量情况
    //步骤 :
    //1. 查询登录用户的所有管辖部门：(√)
    // 使用GLOBAL方式调用部门服务获取用户管辖范围内的所有部门模型对象deptModelList_1，
    // 条件参数如下：
    // _like_resourceCode = 登录用户.userCode + '%'；
    // 然后提取deptModelList_1元素的id属性，得到id属性集合deptIdlist_1；
    //2. 查询管辖部门的月用气量：(√)
    // 根据条件参数查询管辖部门的月用气量(DEPT_MONTHLY_GAS_CONSUME)对象集合deptMonthlyGasConsumeList_1及总数，
    // 额外筛选规则如下：
    // deptMonthlyGasConsumeList_1[i].deptId in deptIdlist_1；
    //3. 返回信息：(√)
    // 根据条件参数和查询到的deptMonthlyGasConsumeList_1及总数生成结果对象并返回；
    //endregion
    //region 参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_deptId", value = "筛选条件 : where deptMonthlyGasConsume.deptId = #{equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_companyId", value = "筛选条件 : where deptMonthlyGasConsume.companyId = #{equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_gasUserType", value = "筛选条件 : where deptMonthlyGasConsume.gasUserType = #{equal_gasUserType}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "greaterthan_date", value = "筛选条件 : where deptMonthlyGasConsume.date > #{greaterthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_date", value = "筛选条件 : where deptMonthlyGasConsume.date >= #{greaterthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_date", value = "筛选条件 : where deptMonthlyGasConsume.date < #{lessthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lessthanorequal_date", value = "筛选条件 : where deptMonthlyGasConsume.date <= #{lessthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "orderBy_date", value = "排序 : order by deptMonthlyGasConsume.date #{orderBy_date}",required = false, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_is_paging", value = "是否分页", defaultValue = "true",required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_deptId", value = "筛选条件 : where deptMonthlyGasConsume.deptId = #{_equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_companyId", value = "筛选条件 : where deptMonthlyGasConsume.companyId = #{_equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_gasUserType", value = "筛选条件 : where deptMonthlyGasConsume.gasUserType = #{_equal_gasUserType}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthan_date", value = "筛选条件 : where deptMonthlyGasConsume.date > #{_greaterthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_date", value = "筛选条件 : where deptMonthlyGasConsume.date >= #{_greaterthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_date", value = "筛选条件 : where deptMonthlyGasConsume.date < #{_lessthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_lessthanorequal_date", value = "筛选条件 : where deptMonthlyGasConsume.date <= #{_lessthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_orderBy_date", value = "排序 : order by deptMonthlyGasConsume.date #{_orderBy_date}",required = false, dataType = "string", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/dept-monthly-gas-consumes", method = RequestMethod.GET)
    //endregion
    public DeptMonthlyGasConsumeGetModel get(Map<String, String> header, Map<String, Object> query) throws ServiceException {
        /* 查询登录用户管辖部门的月用气量情况 */
        DeptMonthlyGasConsumeCustomQueryModel queryModel = deptMonthlyGasConsumeConvertor.deptMonthlyGasConsumeService_query2queryModel(query);

        /* 查询管辖部门的月用气量 */
        List<DeptMonthlyGasConsumeEntityExt> extList = null;
        String show = HzhrTypeUtil.object2string(query.get("_show"));
        if (!StringUtils.isEmpty(show)) {
            extList = deptMonthlyGasConsumeDao.selectExtList(queryModel);
        }
        Integer total = null;
        Boolean showTotal = HzhrTypeUtil.object2boolean(query.get("_show_total"));
        if (showTotal != null && showTotal) {
            total = deptMonthlyGasConsumeDao.selectCount(queryModel);
        }

        /* 返回信息 */
        DeptMonthlyGasConsumeGetModel result = deptMonthlyGasConsumeConvertor.extList2deptMonthlyGasConsumeGetModel(extList, total, null, query);
        return result;
    }

    //region javadoc注释 : getDataSum
    /**
     * 查询登录用户管辖部门的月用气量总和 <br/><br/>
     * 简介&nbsp;:&nbsp;查询登录用户管辖部门的月用气量总和 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询登录用户的所有管辖部门：(√) <br/>
     * &nbsp;使用GLOBAL方式调用部门服务获取用户管辖范围内的所有部门模型对象deptModelList_1， <br/>
     * &nbsp;条件参数如下： <br/>
     * &nbsp;_like_resourceCode&nbsp;=&nbsp;登录用户.userCode&nbsp;+&nbsp;'%'； <br/>
     * &nbsp;然后提取deptModelList_1元素的id属性，得到id属性集合deptIdlist_1； <br/>
     * 2.&nbsp;查询管辖部门的月用气量总和：(√) <br/>
     * &nbsp;根据条件参数查询管辖部门的月用气量(DEPT_DAILY_GAS_CONSUME)对象集合deptMonthlyGasConsumeList_1元素的data属性的总和dataSum， <br/>
     * &nbsp;额外筛选规则如下： <br/>
     * &nbsp;deptMonthlyGasConsumeList_1[i].deptId&nbsp;in&nbsp;deptIdlist_1； <br/>
     * 3.&nbsp;返回信息：(√) <br/>
     * &nbsp;生成结果对象result，设置属性并返回， <br/>
     * &nbsp;属性设置规则： <br/>
     * &nbsp;result.dataSum&nbsp;=&nbsp;dataSum； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _equal_deptId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.deptId = #{_equal_deptId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_companyId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.companyId = #{_equal_companyId};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _equal_gasUserType : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.gasUserType = #{_equal_gasUserType};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _greaterthan_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.date > #{_greaterthan_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _greaterthanorequal_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.date >= #{_greaterthanorequal_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _lessthan_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.date < #{_lessthan_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _lessthanorequal_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where deptDailyGasConsume.date <= #{_lessthanorequal_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/><br/>
     * @throws ServiceException <br/>
     * @see DeptMonthlyGasConsumeDataSumModel result <br/>
     */ 
    //endregion
    //region 说明 : getDataSum
    //查询登录用户管辖部门的月用气量总和
    //简介 : 查询登录用户管辖部门的月用气量总和
    //步骤 :
    //1. 查询登录用户的所有管辖部门：(√)
    // 使用GLOBAL方式调用部门服务获取用户管辖范围内的所有部门模型对象deptModelList_1，
    // 条件参数如下：
    // _like_resourceCode = 登录用户.userCode + '%'；
    // 然后提取deptModelList_1元素的id属性，得到id属性集合deptIdlist_1；
    //2. 查询管辖部门的月用气量总和：(√)
    // 根据条件参数查询管辖部门的月用气量(DEPT_DAILY_GAS_CONSUME)对象集合deptMonthlyGasConsumeList_1元素的data属性的总和dataSum，
    // 额外筛选规则如下：
    // deptMonthlyGasConsumeList_1[i].deptId in deptIdlist_1；
    //3. 返回信息：(√)
    // 生成结果对象result，设置属性并返回，
    // 属性设置规则：
    // result.dataSum = dataSum；
    //endregion
    //region 参数 : getDataSum
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "equal_deptId", value = "筛选条件 : where deptDailyGasConsume.deptId = #{equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_companyId", value = "筛选条件 : where deptDailyGasConsume.companyId = #{equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_gasUserType", value = "筛选条件 : where deptDailyGasConsume.gasUserType = #{equal_gasUserType}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "greaterthan_date", value = "筛选条件 : where deptDailyGasConsume.date > #{greaterthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_date", value = "筛选条件 : where deptDailyGasConsume.date >= #{greaterthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_date", value = "筛选条件 : where deptDailyGasConsume.date < #{lessthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lessthanorequal_date", value = "筛选条件 : where deptDailyGasConsume.date <= #{lessthanorequal_date}",required = false, dataType = "string", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_equal_deptId", value = "筛选条件 : where deptDailyGasConsume.deptId = #{_equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_companyId", value = "筛选条件 : where deptDailyGasConsume.companyId = #{_equal_companyId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_gasUserType", value = "筛选条件 : where deptDailyGasConsume.gasUserType = #{_equal_gasUserType}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthan_date", value = "筛选条件 : where deptDailyGasConsume.date > #{_greaterthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_date", value = "筛选条件 : where deptDailyGasConsume.date >= #{_greaterthanorequal_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_date", value = "筛选条件 : where deptDailyGasConsume.date < #{_lessthan_date}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_lessthanorequal_date", value = "筛选条件 : where deptDailyGasConsume.date <= #{_lessthanorequal_date}",required = false, dataType = "string", paramType = "query"),
    })
    //endregion
    //region 请求 : getDataSum
    @RequestMapping(value = "/dept-monthly-gas-consumes/data-sum", method = RequestMethod.GET)
    //endregion
    public DeptMonthlyGasConsumeDataSumModel getDataSum(Map<String, String> header, Map<String, Object> query) throws ServiceException {
        /* 查询登录用户的所有管辖部门 */
        Integer deptId = getDeptId(header);
        String userDeptCode = user_deptServiceHelper.getById(initHeader(header), deptId).getCode();
        List<Integer> deptIds = user_deptServiceHelper.getDeptIdAndSubDeptIdListByDeptCode(initHeader(header), userDeptCode);

        /* 查询管辖部门的月用气量总和 */
        DeptMonthlyGasConsumeCustomQueryModel queryModel = deptMonthlyGasConsumeConvertor.deptMonthlyGasConsumeService_query2queryModel(query);
        queryModel.setIn_deptId(deptIds);
        Double dataSum = deptMonthlyGasConsumeDao.selectDataSum(queryModel);

        /* 返回信息 */
        DeptMonthlyGasConsumeDataSumModel result = new DeptMonthlyGasConsumeDataSumModel();
        result.setDataSum(dataSum);
        return result;
    }

    //region javadoc注释 : getMonthDataSum
    /**
     * 查询部门的月用气量每月总和 <br/><br/>
     * 简介&nbsp;:&nbsp;查询部门的月用气量每月总和 <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _deptId : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _greaterthanorequal_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where DeptDailyGasConsumeModel.date >= #{_greaterthanorequal_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _lessthan_date : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 筛选条件 : where DeptDailyGasConsumeModel.date < #{_lessthan_date};<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/><br/>
     * @throws ServiceException <br/>
     * @see DeptMonthlyGasConsumeMonthDataSumModel result <br/>
     */ 
    //endregion
    //region 说明 : getMonthDataSum
    //查询部门的月用气量每月总和
    //简介 : 查询部门的月用气量每月总和
    //endregion
    //region 参数 : getMonthDataSum
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "deptId", value = "部门编号",required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_date", value = "筛选条件 : where DeptDailyGasConsumeModel.date >= #{greaterthanorequal_date}",required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_date", value = "筛选条件 : where DeptDailyGasConsumeModel.date < #{lessthan_date}",required = true, dataType = "string", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_deptId", value = "部门编号",required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_date", value = "筛选条件 : where DeptDailyGasConsumeModel.date >= #{_greaterthanorequal_date}",required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_date", value = "筛选条件 : where DeptDailyGasConsumeModel.date < #{_lessthan_date}",required = true, dataType = "string", paramType = "query"),
    })
    //endregion
    //region 请求 : getMonthDataSum
    @RequestMapping(value = "/dept-monthly-gas-consumes/month-data-sum", method = RequestMethod.GET)
    //endregion
    public DeptMonthlyGasConsumeMonthDataSumModel getMonthDataSum(Map<String, String> header, Map<String, Object> query) throws ServiceException {
        /* 查询部门的日用气量每日总和 */
        Integer deptId = HzhrTypeUtil.object2integer(query.get("_deptId"));
        String userDeptCode = user_deptServiceHelper.getById(initHeader(header), deptId).getCode();
        List<Integer> deptIds = user_deptServiceHelper.getDeptIdAndSubDeptIdListByDeptCode(initHeader(header), userDeptCode);
        DeptMonthlyGasConsumeCustomQueryModel queryModel = deptMonthlyGasConsumeConvertor.deptMonthlyGasConsumeService_query2queryModel(query);
        queryModel.setIn_deptId(deptIds);
        List<Map<String, Object>> dayDataSumList = deptMonthlyGasConsumeEntityCustomMapper.selectMonthDataSum(queryModel);

        /* 返回信息 */
        DeptMonthlyGasConsumeMonthDataSumModel result = new DeptMonthlyGasConsumeMonthDataSumModel();
        List<String> monthList = new ArrayList<>();
        List<Double> dataSumList = new ArrayList<>();
        result.setMonthList(monthList);
        result.setDataSumList(dataSumList);
        for (Map<String, Object> dayDataSum :
                dayDataSumList) {
            String month = HzhrDateUtil.dateToStr(HzhrDateUtil.strToDate(dayDataSum.get("month").toString()), "yyyy-MM");
            monthList.add(month);
            Double dataSum = HzhrTypeUtil.object2double(dayDataSum.get("data"));
            dataSum = dataSum == null ? 0.0 : dataSum;
            dataSumList.add(dataSum);
        }

        return result;
    }
}





































































































































































































































































































































































































































